package com.xsr;

import com.xsr.entity.User;
import com.xsr.entity.UserExt;
import com.xsr.proxy.FangDongService;
import com.xsr.proxy.ProxyFangServiceImpl;
import com.xsr.service.UserService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project spring03
 * @date 2022/9/5 14:56
 */
public class test {
    @Test
    public  void test02(){
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserExt userExt =(UserExt) classPathXmlApplicationContext.getBean("userExt");
        System.out.println(userExt);
    }
    @Test
    public void testSpring(){
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService =(UserService) classPathXmlApplicationContext.getBean("userService");
        ((ClassPathXmlApplicationContext)classPathXmlApplicationContext).close();

    }
    //多例模式 不需要的时候会被jvm垃圾回收
    @Test
    public void testSpring1() {
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        FangDongService proxyFangDong = (ProxyFangServiceImpl)classPathXmlApplicationContext.getBean("proxyFangDong");
        proxyFangDong.zuFang();
    }
}
